# encoding: utf-8
"""
!/usr/bin/python3
@Author: Gao Shuo
@Time: 2018/8/25 13:27 
@ReadMe:已经停用
    Input: 列出所有颜色
    Output:

"""
import glob

from PIL import Image
import os.path
import sys
if __name__ == "__main__":
    path = sys.argv[1]
    width = 800
    height = 480
    # 共有多少颜色
    colorListAll = []
    # *多选文件
    # for filename in glob.glob(path):
    #     im = Image.open(filename)
    #     for i in range(width):
    #         for j in range(height):
    #             color = im.getpixel(xy=(i, j))
    #             if color not in colorListAll:
    #                 colorListAll.append(color)
    #     print 'finish: ' + filename
    # 文件夹
    li = os.listdir(path)
    for filepath in li:
        filein =  os.path.join(path, filepath)
        im = Image.open(filein)
        for i in range(width):
            for j in range(height):
                color =  im.getpixel(xy = (i,j))
                if color not in colorListAll:
                    colorListAll.append(color)
        print 'finish: '+ filein
    colorListAll.sort()
    print colorListAll
    print len(colorListAll)
    # 输出到文件
    # dest = sys.argv[2]
    # output = open(dest , 'w')
    # for color in colorListAll:
    #     output.write(str(color)+'\n')
    # output.close()



